#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>

void* thread_func(void* arg)
{
    //pthread_detach(pthread_self());//设置分离属性
    int i = *((int*)arg);
    while (i--)
    {
        sleep(1);
        printf("i==%d\n", i);
    }
    int* ret = malloc(4);
    *ret = 250;
    pthread_exit(ret);//返回的退出码
}

int main()
{
    int times;
    scanf("%d", &times);

    pthread_t tid;
    pthread_create(&tid, NULL, thread_func, (void*)&times);

    int* p = NULL;
    pthread_join(tid, (void**)&p);//阻塞等待
    printf("malloc:%d\n", *p);
    free(p);
}